package com.solute.utils.services.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.solute.domain.ImageVO;

@Component
public interface ImageDao {
	@Insert({
		"insert into images (",
		"   id",
		"  ,path",
		") VALUES (",
		"   #{id}  /* id - IN varchar(32) */",
		"  ,#{path}  /* path - IN varchar(256) */",
		")"
	})
	public <T> void insertImage(T param);
	
	@Insert({
		"insert into image_group (",
		"   gid",
		"  ,image_id",
		") VALUES (",
		"   #{gid}  /* gid - IN varchar(36) */",
		"  ,#{imgId}  /* image_id - IN varchar(36) */",
		")"
	})
	public <T> void insertImageGroup(T param);
	
	@Select({
		"select id, path from images where id = #{id}"
	})
	public <T> ImageVO selectImageById(T id);
	
	@Select({
		"SELECT count(*) FROM images \n"
	})
	public int selectNumImages();
	
	@Select({
		"SELECT count(*) FROM image_group \n"
	})
	public int selectNumImageGroups();
	
	@Delete({
		"delete from image_group"
	})
	public void deleteImageGroups();
	
	@Delete({
		"delete from images"
	})
	public void deleteImages();
}
